<?php
  include_once('staff.php');
  
  if(isset($_REQUEST['spec'])){
    $spec = $_REQUEST['spec'];
  }else{
    $spec = '';
  }
  $sql = "SELECT name,id FROM subj WHERE spec_id = '$spec' ";
  $db = connectdb();
  $res = mysql_query($sql,$db);
  $subj = array();
  if(mysql_num_rows($res) > 0){
    while($row = mysql_fetch_assoc($res)){
		$row['name']=iconv('CP1251','UTF-8',$row['name']);
		$subj[] = $row['name'];
		$subj[][]=$row['id'];
    } 
  }  
  $tmp = json_encode($subj);
  //print_r($subj);
  echo $tmp;
?>